#!/usr/bin/env python
# -*— coding: utf-8 -*-

from multiprocessing import Process
import os
import time

class Process_Class(Process):
  def __init__(self, interval):
    Process.__init__(self)
    #super().__init__(self)
    # super(Process_Class, self).__init__()
    self.interval = interval
  
  def run(self):
    print('子进程（%s）开始执行，父进程为（%s）'%(os.getpid(),os.getppid()))
    tStart = time.time()
    time.sleep(self.interval)
    tStop = time.time()
    print('(%s)执行结束，耗时%0.2f秒'%(os.getpid(),tStop-tStart))
  

if __name__ == '__main__':
  tStart = time.time()
  print('当前程序进程（%s）'%os.getpid())
  p1 = Process_Class(2)
  p1.start()
  p1.join()
  print('子进程已结束')